本文整理汇总了PHP中Assets::js方法的典型用法代码示例。如果您正苦于以下问题:PHP Assets::js方法的具体用法?PHP Assets::js怎么用?PHP Assets::js使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assets
的用法示例。
在下文中一共展示了Assets::js方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: before
public function before()
{
parent::before();
if ($this->auto_render === TRUE) {
Assets::js('jquery', ADMIN_RESOURCES . 'libs/jquery.min.js');
Assets::package(array('jquery-ui', 'backbone', 'notify', 'underscore', 'select2', 'core', 'bootstrap'));
}
}
示例2: action_index
public function action_index()
{
Assets::package('jquery-ui');
Assets::css('fullcalendar', ADMIN_RESOURCES . 'libs/fullcalendar-2.1.0/fullcalendar.min.css', 'global');
Assets::js('fullcalendar', ADMIN_RESOURCES . 'libs/fullcalendar-2.1.0/fullcalendar.min.js', 'jquery');
Assets::js('fullcalendar.lang', ADMIN_RESOURCES . 'libs/fullcalendar-2.1.0/lang/' . I18n::lang_short() . '.js', 'fullcalendar');
$this->set_title(__('Calendar'), FALSE);
$this->template->content = View::factory('calendar/index', array('colors' => array('default', 'darken', 'danger', 'info', 'primary', 'success', 'warning'), 'icons' => array('info', 'warning', 'check', 'user', 'lock', 'clock-o')));
}
示例3: testRenderJs
/**
* Tests whether JS files can be combined, minified,
* and cached successfully. Verfies returned HTML
* tag and checks to see whether cached file exists.
* @return void
*/
public function testRenderJs()
{
Assets::js(array('plugins.js', 'functions.js'));
Assets::coffee('test.coffee');
// Does returned tag match expected output?
$this->assertTrue(Assets::renderJs() == "<script type=\"text/javascript\" src=\"/assets/cache/" . Assets::getCompiledName('js') . "\"></script>");
// Does file exist?
$this->filename = __DIR__ . '/assets/cache/' . Assets::getCompiledName('js');
$this->assertTrue(file_exists($this->filename));
}
示例4: before
public function before()
{
parent::before();
if (file_exists(CMSPATH . FileSystem::normalize_path('media/js/i18n/' . I18n::lang() . '-message.js'))) {
Assets::js('i18n', ADMIN_RESOURCES . 'js/i18n/' . I18n::lang() . '-message.js', 'global');
}
if ($this->request->action() != 'logout' and Auth::is_logged_in()) {
$this->go_home();
}
}
示例5: action_index
public function action_index()
{
\Assets::css('page2', base_UI . 'css/rangeslider.css');
\Assets::js('page1', base_UI . 'js/plugins/range/rangeslider.min.js');
\Assets::js('page2', base_UI . 'js/plugins/range/range_script.js');
\Assets::js('attr', base_UI . 'js/pages/attr.js');
\Assets::js('jumper', base_UI . 'js/index/recovery_pass_jumper.js');
$user_id = \Registry::getCurrentUser()->iduser;
$data_formula = $this->dataFormula();
$this->template->assign(['data_formula' => $data_formula]);
$this->response->body($this->template->fetch('main.tpl'));
}
示例6: action_message
public function action_message()
{
\Assets::js('page', base_UI . 'js/pages/chat.js');
$user_id = \Registry::getCurrentUser()->id;
$receiver_id = $this->request->param('id');
$receiver = \Model\User::model()->findByPk($receiver_id);
$criteria = new \DBCriteria();
$criteria->condition = ' ( session = "' . $receiver_id . "#" . $user_id . '" ) OR
( session = "' . $user_id . "#" . $receiver_id . '" ) ';
$session = \Model\Chat::model()->find($criteria);
$short_history = $this->userCustomHistory($user_id, $receiver_id, $session->session, $this->user_messages);
$this->template->assign(['short_history' => $short_history, 'session' => $session->session, 'receiver' => $receiver]);
$this->response->body($this->template->fetch('chat/message.tpl'));
}
示例7: set
/**
* Add hook for shortcode tag
*
* There can only be one hook for each shortcode.
* Which means that if another plugin has a similar shortcode, it will
* override yours or yours will override theirs depending on which order
* the plugins are included and/or ran.
*
* @param string $tag Shortcode tag to be searched in post content.
* @param callable $callback Hook to run when shortcode is found.
* @param string|boolean $asset CSS or JS or both to be added. css|js|both [Optional]
*
* @return array
*
* @throws Gleez_Exception
*
* @uses Assets::css
* @uses Assets::js
*/
public static function set($tag, $callback, $asset = FALSE)
{
if (!is_callable($callback)) {
throw new Gleez_Exception('Invalid Shortcode::callback specified');
}
self::$_tags[$tag] = $callback;
if ($asset and $asset == 'css') {
Assets::css($tag, "media/css/shortcodes/{$tag}.css");
}
if ($asset and $asset == 'js') {
Assets::js($tag, "media/js/shortcodes/{$tag}.js");
}
return self::$_tags;
}
示例8: action_index
/**
* Listing Widgets
*/
public function action_index()
{
$this->title = __('Widgets');
$view = View::factory('admin/widget/list')->bind('widget_regions', $widget_regions)->bind('weight_delta', $weight_delta)->bind('widgets', $widget_listing);
$widget_regions = array();
$adminTheme = Theme::getTheme();
$frontTheme = Theme::getTheme(Config::get('site.theme', $adminTheme->name));
if (isset($adminTheme->regions) and !empty($adminTheme->regions)) {
$widget_regions = Arr::merge($widget_regions, $adminTheme->regions);
}
if (isset($frontTheme->regions) and !empty($frontTheme->regions)) {
$widget_regions = Arr::merge($widget_regions, $frontTheme->regions);
}
// Add a last region for disabled blocks.
$widget_regions = Arr::merge($widget_regions, array(self::$WIDGET_REGION_NONE => self::$WIDGET_REGION_NONE));
$widgets = ORM::factory('widget')->order_by('region')->order_by('weight')->find_all();
// Weights range from -delta to +delta, so delta should be at least half
// of the amount of blocks present. This makes sure all blocks in the same
// region get an unique weight.
$weight_delta = round(count($widgets) / 2);
if (isset($widget_regions[self::$WIDGET_REGION_NONE])) {
$widget_regions[self::$WIDGET_REGION_NONE] = __('Disabled');
}
foreach ($widget_regions as $key => $value) {
// Initialize an empty array for the region.
$widget_listing[$key] = array();
}
// Initialize disabled widgets array.
$widget_listing[self::$WIDGET_REGION_NONE] = array();
// Add each block in the form to the appropriate place in the widget listing.
foreach ($widgets as $widget) {
// Fetch the region for the current widget.
$region = isset($widget->region) ? $widget->region : self::$WIDGET_REGION_NONE;
$widget_listing[$region][] = $widget;
}
if ($this->valid_post('widget-list')) {
foreach ($_POST['widgets'] as $widget) {
$widget['status'] = (int) ($widget['region'] != self::$WIDGET_REGION_NONE);
$widget['region'] = $widget['status'] ? $widget['region'] : self::$WIDGET_REGION_NONE;
DB::update('widgets')->set(array('status' => $widget['status'], 'weight' => $widget['weight'], 'region' => $widget['region']))->where('id', '=', $widget['id'])->execute();
}
Message::success(__('The Widget settings have been updated.'));
Cache::instance('widgets')->delete_all();
$this->request->redirect(Route::get('admin/widget')->uri());
}
$this->response->body($view);
Assets::tabledrag();
Assets::js('widgets', 'media/js/widgets.js', array('jquery'), FALSE, array('weight' => 5));
}
示例9: action_Edit
public function action_Edit()
{
if ($item_id = \Utils\Protect::Validate($this->request->param('id'), 'int')) {
\Assets::js('sight', base_UI . 'js/admin/pages/Edit.js');
$this->addCKEditor();
$this->addBootstrapModal();
$this->addSelect2();
//Alerts BootBox
\Assets::js('BootBox', base_UI . 'libs/BootBox/bootbox.js');
//Item Data
$data_item = \Model\Pages::model()->findByPk($item_id);
$PageTypes = \Model\PageType::model()->findAll();
$this->template->assign(['data' => $data_item, 'PageTypes' => $PageTypes]);
$this->response->body($this->template->fetch('admin/pages/edit.tpl'));
}
}
示例10: action_revision
public function action_revision()
{
Assets::js('diff_text_tool', ADMIN_RESOURCES . 'libs/diff_match_patch.js', 'global');
Assets::js('part_revision', ADMIN_RESOURCES . 'js/controller/part_revision.js', 'global');
$part_id = (int) $this->request->param('id');
$part = ORM::factory('page_part', $part_id);
$parts = DB::select()->from('part_revision')->order_by('created_on', 'desc')->as_object();
if (!empty($part->id)) {
$page = ORM::factory('page', $part->page_id);
$this->breadcrumbs->add($page->title, Route::get('backend')->uri(array('controller' => 'page', 'action' => 'edit', 'id' => $page->id)));
$this->set_title(__('Revision for part :name', array(':name' => $part->name)));
$parts->where('part_id', '=', $part_id);
} else {
$this->set_title(__('Parts revision'));
}
$this->template->content = View::factory('part/revision', array('part' => $part, 'parts' => $parts->execute()));
}
示例11: action_Edit
public function action_Edit()
{
if ($item_id = \Utils\Protect::Validate($this->request->param('id'), 'int')) {
\Assets::js('sight', base_UI . 'js/admin/Payments/Edit.js');
$this->addCKEditor();
$this->addBootstrapModal();
$this->addSelect2();
//Alerts BootBox
\Assets::js('BootBox', base_UI . 'libs/BootBox/bootbox.js');
//Item Data
$data = \Model\UserPayment::model()->with('iduser0', 'iduserCredit')->findByPk($item_id);
$userCredit = \Model\UserCredit::model()->findAll();
$users = \Model\User::model()->findAll();
$this->template->assign(['data' => $data, 'userCredit' => $userCredit, 'users' => $users]);
$this->response->body($this->template->fetch('admin/payments/edit.tpl'));
}
}
示例12: action_display
public function action_display()
{
$user_id = \Registry::getCurrentUser()->iduser;
if ($item_id = \Utils\Protect::Validate($this->request->param('id'), 'int')) {
\Assets::js('page1', base_UI . 'js/pages/page.js');
$page = \Model\Pages::model()->findByPk($item_id);
$this->template->assign(['page' => $page]);
$this->response->body($this->template->fetch('pages.tpl'));
} else {
if ($alias = \Utils\Protect::Validate($this->request->param('alias'), 'string')) {
/**@var \Model\Item $data*/
\Assets::js('page1', base_UI . 'js/pages/page.js');
$page = \Model\Pages::model()->findByAttributes(['alias' => $alias]);
$this->template->assign(['page' => $page]);
$this->response->body($this->template->fetch('pages.tpl'));
}
}
}
示例13: action_mail
/**
* Sending mails
*
* @since 1.0.0 First time this method was introduced
* @since 1.1.0 Added jQuery Textarea Characters Counter Plugin
*
* @link http://roy-jin.appspot.com/jsp/textareaCounter.jsp
*
* @uses Request::query
* @uses Route::get
* @uses Route::uri
* @uses URL::query
* @uses URL::site
* @uses Validation::rule
* @uses Config::get
* @uses Config::load
* @uses Assets::js
*/
public function action_mail()
{
$this->title = __('Contact us');
$config = Config::load('contact');
Assets::js('textareaCounter', 'media/js/jquery.textareaCounter.plugin.js', array('jquery'), FALSE, array('weight' => 10));
Assets::js('greet/form', 'media/js/greet.form.js', array('textareaCounter'), FALSE, array('weight' => 15));
//Add schema.org support
$this->schemaType = 'ContactPage';
// Set form destination
$destination = !is_null($this->request->query('destination')) ? array('destination' => $this->request->query('destination')) : array();
// Set form action
$action = Route::get('contact')->uri(array('action' => $this->request->action())) . URL::query($destination);
// Get user
$user = User::active_user();
// Set mail types
$types = $config->get('types', array());
$view = View::factory('contact/form')->set('destination', $destination)->set('action', $action)->set('config', $config)->set('types', $types)->set('user', $user)->bind('post', $post)->bind('errors', $this->_errors);
// Initiate Captcha
if ($config->get('use_captcha', FALSE) and !$this->_auth->logged_in()) {
$captcha = Captcha::instance();
$view->set('captcha', $captcha);
}
if ($this->valid_post('contact')) {
$post = Validation_Contact::factory($this->request->post());
if ($post->check()) {
// Create the email subject
$subject = __('[:category] :subject', array(':category' => $types[$post['category']], ':subject' => Text::plain($post['subject'])));
// Create the email body
$body = View::factory('email/contact')->set('name', $post['name'])->set('body', $post['body'])->set('config', Config::load('site'))->render();
// Create an email message
$email = Email::factory()->to(Text::plain($this->_config->get('site_email', 'webmaster@gleezcms.org')), __('Webmaster :site', array(':site' => Template::getSiteName())))->subject($subject)->from($post['email'], Text::plain($post['name']))->message($body, 'text/html');
// @todo message type should be configurable
// Send the message
$email->send();
Log::info(':name sent an e-mail regarding :cat', array(':name' => Text::plain($post['name']), ':cat' => $types[$post['category']]));
Message::success(__('Your message has been sent.'));
// Always redirect after a successful POST to prevent refresh warnings
$this->request->redirect(Route::get('contact')->uri(), 200);
} else {
$this->_errors = $post->errors('contact', TRUE);
}
}
$this->response->body($view);
}
示例14: combine_js
/**
* Javascript (optimized) helper.
* All scripts are optimized for download size and formed into a single file.
* Optimization is done by JShrink\Minimizer.
*
* This file is updated automatically if the files change.
*
* @param $files - array of files to include
* @param $outputdir - where to place the generated files, default is typically adequate.
*/
public static function combine_js($files, $outputdir = 'static/generated/')
{
if (\HMC\Config::SITE_ENVIRONMENT() == 'development') {
Assets::js($files);
return;
}
$ofiles = is_array($files) ? $files : array($files);
$hashFileName = md5(join($ofiles));
$dirty = false;
if (file_exists($outputdir . $hashFileName . '.js')) {
$hfntime = filemtime($outputdir . $hashFileName . '.js');
foreach ($ofiles as $vfile) {
$file = str_replace(\HMC\Config::SITE_URL(), \HMC\Config::SITE_PATH(), $vfile);
if (!$dirty) {
$fmtime = filemtime($file);
if ($fmtime > $hfntime) {
$dirty = true;
}
}
}
} else {
$dirty = true;
}
if ($dirty) {
$buffer = "";
foreach ($ofiles as $vfile) {
$jsFile = str_replace(\HMC\Config::SITE_URL(), \HMC\Config::SITE_PATH(), $vfile);
$buffer .= "\n" . file_get_contents($jsFile);
}
ob_start();
// Write everything out
echo $buffer;
$fc = ob_get_clean();
$minifiedCode = \JShrink\Minifier::minify($fc, array('flaggedComments' => false));
file_put_contents(SITEROOT . $outputdir . $hashFileName . '.js', $minifiedCode);
}
static::resource(str_replace(':||', '://', str_replace('//', '/', str_replace('://', ':||', \HMC\Config::SITE_URL() . $outputdir . $hashFileName . '.js'))), 'js');
}
示例15: init_media
public function init_media()
{
parent::init_media();
$this->template_js_params['ACE_THEME'] = Config::get('ace', 'theme', 'textmate');
$this->template_js_params['DEFAULT_FILTER'] = Config::get('site', 'default_filter_id', '');
Assets::package(array('jquery', 'bootstrap', 'notify', 'select2', 'dropzone', 'fancybox', 'datepicker', 'underscore', 'core'));
foreach (array('.js', '-message.js') as $file_name) {
$filename = Kohana::$cache_dir . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, array('i18n', NULL)) . I18n::lang() . $file_name;
if (file_exists($filename)) {
Assets::js('i18n', BASE_URL . 'cms/cache/i18n/' . I18n::lang() . $file_name, 'global', FALSE, 0);
}
}
$file = $this->request->controller();
$directory = $this->request->directory();
if (!empty($directory)) {
$file = $directory . '/' . $file;
}
$file = strtolower($file);
if (Kohana::find_file('media', FileSystem::normalize_path('js/controller/' . $file), 'js')) {
Assets::js('controller.' . $file, ADMIN_RESOURCES . 'js/controller/' . $file . '.js', 'global', FALSE, 999);
}
Assets::group('global', 'events', '<script type="text/javascript">' . Assets::merge_files('js/events', 'js') . '</script>', 'global');
}