Skip to content

Commit

Permalink
Merge branch 'release-2.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
archetyped committed Oct 30, 2013
2 parents 0655537 + de68de8 commit 3d88a2c
Show file tree
Hide file tree
Showing 21 changed files with 2,449 additions and 2,343 deletions.
4 changes: 2 additions & 2 deletions client/js/lib.admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @author Archetyped
*/

(function ($) {
if ( jQuery ){(function ($) {

if ( !SLB || !SLB.attach ) {
return false;
Expand All @@ -28,4 +28,4 @@ $(document).ready(function() {
SLB.Admin.init();
});

})(jQuery);
})(jQuery);}
5 changes: 2 additions & 3 deletions client/js/lib.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
* @package SLB
* @author Archetyped
*/

(function($) {
if ( jQuery ){(function($) {

/**
* Extendible class
Expand Down Expand Up @@ -588,4 +587,4 @@ this.SLB = new SLB_Core();

SLB.setup_client();

})(jQuery);
})(jQuery);}
31 changes: 29 additions & 2 deletions client/js/lib.view.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @author Archetyped
*/

(function ($) {
if ( jQuery ){(function ($) {

if ( typeof SLB == 'undefined' || !SLB.attach ) {
return false;
Expand Down Expand Up @@ -564,6 +564,10 @@ var View = {
else {
hdl.set_attributes(attr);
}
//Load styles
if ( this.util.in_obj(attr, 'styles') ) {
this.load_styles(attr.styles);
}
return hdl;
},

Expand Down Expand Up @@ -657,6 +661,11 @@ var View = {
$.extend(model, attr);
}

//Load styles
if ( this.util.in_obj(attr, 'styles') ) {
this.load_styles(attr.styles);
}

//Link parent model
if ( this.util.is_string(model.parent) ) {
model.parent = this.get_theme_model(model.parent);
Expand Down Expand Up @@ -707,6 +716,10 @@ var View = {
hdl = hdls[id];
hdl.set_attributes(attr);
}
//Load styles
if ( this.util.in_obj(attr, 'styles') ) {
this.load_styles(attr.styles);
}
return hdl;
},

Expand All @@ -731,6 +744,20 @@ var View = {
}
//Default: Return empty handler
return new this.Template_Tag_Handler(id, {});
},

/**
* Load styles
* @param array styles Styles to load
*/
load_styles: function(styles) {
if ( this.util.is_array(styles) ) {
var out = '';
$.each(styles, function(i, style) {
out += '<link rel="stylesheet" type="text/css" href="' + style.uri + '" />';
});
$('head').append(out);
}
}
};

Expand Down Expand Up @@ -4516,4 +4543,4 @@ View.Template_Tag_Handler = Component.extend(Template_Tag_Handler);
SLB.attach('View', View);
View = SLB.View;
View.update_refs();
})(jQuery);
})(jQuery);}
23 changes: 1 addition & 22 deletions controller.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

/**
* Model (Core functionality)
* Controller
* @package Simple Lightbox
* @author Archetyped
*/
Expand Down Expand Up @@ -158,7 +157,6 @@ public function _hooks_init() {

/**
* Init options
*
*/
protected function _options() {
//Setup options
Expand Down Expand Up @@ -916,25 +914,6 @@ private function has_cached_media_items() {
return ( empty($this->media_items_raw) ) ? false : true;
}

/*-** Theme **-*/

/**
* Retrieve theme
* @param string $id ID of theme to retrieve
* @return SLB_Theme Theme instance
* @TODO Refactor
*/
function get_theme($id = '') {
//Default: Get current theme if no theme specified
if ( !$this->themes->has_item($id) ) {
$id = $this->options->get_value('theme');
if ( !$this->themes->has_item($id) ) {
$id = $this->themes->get_default_id();
}
}
return $this->themes->get_item($id);
}

/*-** Grouping **-*/

/**
Expand Down
10 changes: 5 additions & 5 deletions includes/class.base.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ class SLB_Base {
function __construct() {
$this->util = new SLB_Utilities($this);
if ( $this->can('init') ) {
$hook = 'plugins_loaded';
if ( current_filter() == $hook || self::$_init_passed ) {
$hook = 'init';
if ( did_action($hook) || self::$_init_passed ) {
$this->_init();
} else {
add_action($hook, $this->m('_init'));
add_action($hook, $this->m('_init'), 1);
}
}
}
Expand Down Expand Up @@ -281,7 +281,7 @@ public function register_client_files() {
continue;
foreach ( $files as $f ) {
//Get file URI
$f->file = ( !$this->util->is_file($f->file) && is_callable($f->file) ) ? call_user_func($f->file) : $this->util->get_file_url($f->file);
$f->file = ( !$this->util->is_file($f->file) && is_callable($f->file) ) ? call_user_func($f->file) : $this->util->get_file_url($f->file, true);
$params = array($f->id, $f->file, $f->deps, $v);
//Set additional parameters based on file type (script, style, etc.)
switch ( $type ) {
Expand Down Expand Up @@ -354,7 +354,7 @@ function enqueue_client_files($footer = false) {
}
}
}

/**
* Enqueue client files in the footer
*/
Expand Down
17 changes: 15 additions & 2 deletions includes/class.component.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,11 @@ public function set_styles($styles) {
* @return string Formatted handle
*/
public function get_handle($base_handle) {
return $this->add_prefix( array('theme', $this->get_id(), $base_handle), '-');
return $this->add_prefix( array('asset', $this->get_id(), $base_handle), '-');
}

/**
* Enqueue files in client
*
* @param string $type (optional) Type of file to load (singular) (Default: All client file types)
*/
public function enqueue_client_files($type = null) {
Expand Down Expand Up @@ -98,6 +97,20 @@ public function enqueue_client_files($type = null) {
}
}

/**
* Enqueue scripts
*/
public function enqueue_scripts() {
$this->enqueue_client_files('script');
}

/**
* Enqueue styles
*/
public function enqueue_styles() {
$this->enqueue_client_files('style');
}

/* Helpers */

/**
Expand Down
37 changes: 34 additions & 3 deletions includes/class.content_handlers.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ protected function _hooks() {
parent::_hooks();
$this->util->add_action('init', $this->m('init_defaults'));
$this->util->add_action('footer', $this->m('client_output'), 1, 0, false);
$this->util->add_filter('footer_script', $this->m('client_output_script'), $this->util->priority('client_footer_output'), 1, false);
}

/* Collection Management */
Expand Down Expand Up @@ -177,12 +178,13 @@ protected function get_cache_props() {
* @param SLB_Content_Handlers $handlers Handlers controller
*/
public function init_defaults($handlers) {
$src_base = $this->util->get_file_url('content-handlers', true);
$defaults = array (
'image' => array (
'match' => $this->m('match_image'),
'scripts' => array (
array ( 'base', $this->util->get_file_path('content-handlers/image/handler.image.js', true) ),
)
array ( 'base', $src_base . '/image/handler.image.js' ),
),
)
);
foreach ( $defaults as $id => $props ) {
Expand Down Expand Up @@ -216,7 +218,36 @@ public function match_image($uri) {
public function client_output() {
//Get handlers for current request
foreach ( $this->request_matches as $handler ) {
$handler->enqueue_client_files();
$handler->enqueue_scripts();
}
}

/**
* Client output script
* @param array $commands Client script commands
* @return array Modified script commands
*/
public function client_output_script($commands) {
$out = array('/* CHDL */');
$code = array();

foreach ( $this->request_matches as $handler ) {
$styles = $handler->get_styles();
if ( empty($styles) ) {
continue;
}
//Setup client parameters
$params = array(
sprintf("'%s'", $handler->get_id()),
);
$params[] = json_encode( array('styles' => array_values($styles)) );
//Extend handler in client
$code[] = $this->util->call_client_method('View.extend_content_handler', $params, false);
}
if ( !empty($code) ) {
$out[] = implode('', $code);
$commands[] = implode(PHP_EOL, $out);
}
return $commands;
}
}
2 changes: 2 additions & 0 deletions includes/class.field.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
class SLB_Field extends SLB_Field_Type {}
Loading

0 comments on commit 3d88a2c

Please sign in to comment.