duplicate error fixed and css inside widgets fixed, duplicate location fixed

This commit is contained in:
Harry Bomrah 2013-04-22 12:24:09 +08:00 committed by saurabhbhatia
parent dc94283af9
commit ae8033ea1b
5 changed files with 69 additions and 219 deletions

View File

@ -6,7 +6,8 @@
//container=true is the area where the view will be loaded //container=true is the area where the view will be loaded
//load = true is used to load the submenu item by default //load = true is used to load the submenu item by default
//response-type = "json"|"script"|"xml|html" default is json //response-type = "json"|"script"|"xml|html" default is json
//autocomplete-list = "listname" an array from which autocomplete will be attached to its respective input or textarea //autocomplete = "url" this will automatically convert textarea or input to autocomplete.
//autocomplete-format = "--:[text,email]" first one is seperator which will be put on between every field.
//ajax-remote="get/delete/post/false" this will automatically bind the <a> with remote ajax call. By default if the resposne is html, it ll be inserted in container=true, false option will not make any calls and also stop page refresh //ajax-remote="get/delete/post/false" this will automatically bind the <a> with remote ajax call. By default if the resposne is html, it ll be inserted in container=true, false option will not make any calls and also stop page refresh
// content-holder = "jquery dom", the returned html of server will be put inside the dom mentioned in content-holder of a tag. this can be used in a tags as attributes // content-holder = "jquery dom", the returned html of server will be put inside the dom mentioned in content-holder of a tag. this can be used in a tags as attributes
//confirm-message ="Some message", this will prompt user with a confirm box and show the message before ajax call is made. //confirm-message ="Some message", this will prompt user with a confirm box and show the message before ajax call is made.
@ -342,38 +343,13 @@ var orbitDesktop = function(dom){
return split( term ).pop(); return split( term ).pop();
} }
var autocompleteListName = null;
$("body").on("keydown","*[autocomplete-list]", function( event ) {
autocompleteListName = $(this).attr("autocomplete-list");
if ( event.keyCode === $.ui.keyCode.TAB &&
$( this ).data( "autocomplete" ).menu.active ) {
event.preventDefault();
}
$(this).autocomplete({
minLength: 0,
source: function( request, response ) {
// delegate back to autocomplete, but extract the last term
response( $.ui.autocomplete.filter(
window.o[o.data_method][autocompleteListName], extractLast( request.term ) ) );
},
focus: function() {
// prevent value inserted on focus
return false;
},
select: function( event, ui ) {
var terms = split( this.value );
// remove the current input
terms.pop();
// add the selected item
terms.push( ui.item.value );
// add placeholder to get the comma-and-space at the end
terms.push( "" );
this.value = terms.join( ", " );
return false;
}
});
});
// $("body").on("keydown","*[autocomplete]", function( event ) {
// var autocompleteList = $(this).attr("autocomplete-list");
// console.log($(this));
// });
//
}; };
this.layout_data = function(h){ this.layout_data = function(h){
@ -466,6 +442,8 @@ var orbitDesktop = function(dom){
} }
} }
o.tinyscrollbar_ext(settings,tsettings); o.tinyscrollbar_ext(settings,tsettings);
o.autocomplete();
o.use_select2();
} }
this.paging = true; this.paging = true;
this.pagination = function(link,variable,page_no){ this.pagination = function(link,variable,page_no){
@ -1611,6 +1589,53 @@ var orbitDesktop = function(dom){
// minimumInputLength: -1 // minimumInputLength: -1
}); });
} }
this.autocomplete = function(){
$("*[autocomplete]").each(function(){
$e = $(this);
var options = {
multiple:true,
minimumInputLength: -1,
width: "off",
ajax: {
url: $e.attr("autocomplete"),
dataType: 'json',
quietMillis: 100,
tokenSeparators: [","],
data: function (search, page) {
return {q: search};
},
results: function (data, page) {
return {results: data.results};
}
}
}
var format = $e.attr("autocomplete-format");
if(format){
format = format.split(":");
var seperator = format[0];
var fields = format[1];
fields = fields.replace("]","");
fields = fields.replace("[","");
fields = fields.split(",");
options.formatResult = function(data){
var markup = "";
var x = 0;
for(i in fields){
if(x > 0)markup += " " + seperator + " ";
x++;
if(data[fields[i]])
markup += data[fields[i]];
else
markup += fields[i] + " not available";
}
return markup;
}
}
$e.select2(options);
})
}
this.appname_substr = function(target,length){ this.appname_substr = function(target,length){
var $target = $(target), var $target = $(target),
length = (length && typeof length == 'number') ? length : 12, length = (length && typeof length == 'number') ? length : 12,

View File

@ -62,51 +62,11 @@ orbitDesktop.prototype.initializeConferencePapers = function(target,url,cache){
}); });
} }
var tokesplits = function(){
$("#writing_conference_author_tokens").select2({
multiple: true,
minimumInputLength: 1,
width: "300px;",
formatResult: function movieFormatResult(coAuthor) {
var markup = "";
if (coAuthor.text !== undefined && coAuthor.email !== undefined) {
if(!coAuthor.email){
markup += coAuthor.text + " -- none email";
} else {
markup += coAuthor.text + " -- " + coAuthor.email;
}
}else if (coAuthor.email !== undefined) {
markup += coAuthor.text;
}
return markup;
},
ajax: {
url: "/panel/personal_conference/desktop/conference_pages/new.json",
dataType: 'json',
quietMillis: 100,
tokenSeparators: [","],
data: function (search, page) {
return {q: search};
},
results: function (data, page) {
return {results: data.results};
}
},
});
$("#writing_conference_author_tokens").select2("container").find("ul.select2-choices").sortable({
containment: 'parent',
start: function() { $("#writing_conference_author_tokens").select2("onSortStart"); },
update: function() { $("#writing_conference_author_tokens").select2("onSortEnd"); }
});
}
var preData = function(){ var preData = function(){
$("#writing_conference_author_tokens").select2('data', JSON.parse($("#writing_conference_author_tokens").attr('data-pre'))); $("#writing_conference_author_tokens").select2('data', JSON.parse($("#writing_conference_author_tokens").attr('data-pre')));
} }
uploadFiles(); uploadFiles();
tokesplits();
preData(); preData();
} }
@ -130,53 +90,11 @@ orbitDesktop.prototype.initializeConferencePapers = function(target,url,cache){
}); });
} }
console.log("hi");
var bindHandlers = function(){ var bindHandlers = function(){
o.simple_drop_down(); o.simple_drop_down();
} }
var tokesplits = function(){
$("#writing_conference_author_tokens").select2({
multiple: true,
minimumInputLength: 1,
width: "300px;",
formatResult: function movieFormatResult(coAuthor) {
var markup = "";
if (coAuthor.text !== undefined && coAuthor.email !== undefined) {
if(!coAuthor.email){
markup += coAuthor.text + " -- none email";
} else {
markup += coAuthor.text + " -- " + coAuthor.email;
}
}else if (coAuthor.email !== undefined) {
markup += coAuthor.text;
}
return markup;
},
ajax: {
url: "/panel/personal_conference/desktop/conference_pages/new.json",
dataType: 'json',
quietMillis: 100,
tokenSeparators: [","],
data: function (search, page) {
return {q: search};
},
results: function (data, page) {
return {results: data.results};
}
},
});
$("#writing_conference_author_tokens").select2("container").find("ul.select2-choices").sortable({
containment: 'parent',
start: function() { $("#writing_conference_author_tokens").select2("onSortStart"); },
update: function() { $("#writing_conference_author_tokens").select2("onSortEnd"); }
});
}
bindHandlers(); bindHandlers();
uploadFiles(); uploadFiles();
tokesplits();
} }
this.initializeConferencePapers.conference = function(){ // to open add pages in conference papers page this.initializeConferencePapers.conference = function(){ // to open add pages in conference papers page

View File

@ -50,7 +50,8 @@
size: "20", size: "20",
placeholder: t("personal_conference.conference_title"), placeholder: t("personal_conference.conference_title"),
class: "s_grid_12 s_grid", class: "s_grid_12 s_grid",
# "autocomplete-list" => "conference_title_autocomplete_list", "autocomplete" => "/panel/personal_conference/desktop/conference_pages/new.json",
"autocomplete-format" => "--:[text,email]",
value: (@writing_conference.conference_title_translations[locale.to_s] rescue nil) %> value: (@writing_conference.conference_title_translations[locale.to_s] rescue nil) %>
<% end %> <% end %>
@ -109,6 +110,8 @@
class: "s_grid_12 s_grid", class: "s_grid_12 s_grid",
size: "20x2", size: "20x2",
placeholder: t("personal_conference.authors"), placeholder: t("personal_conference.authors"),
"autocomplete" => "/panel/personal_conference/desktop/conference_pages/new.json",
"autocomplete-format" => "--:[text,email]",
"data-pre" => generate_authors_name(@writing_conference.conference_co_author_ids) %> "data-pre" => generate_authors_name(@writing_conference.conference_co_author_ids) %>
<%#= f.fields_for :authors_translations do |f| %> <%#= f.fields_for :authors_translations do |f| %>
<%#= f.text_area locale, <%#= f.text_area locale,

View File

@ -63,51 +63,11 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ //
}); });
} }
var tokesplits = function(){
$("#writing_journal_author_tokens").select2({
multiple: true,
minimumInputLength: -1,
width: "off",
formatResult: function movieFormatResult(coAuthor) {
var markup = "";
if (coAuthor.text !== undefined && coAuthor.email !== undefined) {
if(!coAuthor.email){
markup += coAuthor.text + " -- none email";
} else {
markup += coAuthor.text + " -- " + coAuthor.email;
}
}else if (coAuthor.email !== undefined) {
markup += coAuthor.text;
}
return markup;
},
ajax: {
url: "/panel/personal_journal/desktop/journal_pages/new.json",
dataType: 'json',
quietMillis: 100,
tokenSeparators: [","],
data: function (search, page) {
return {q: search};
},
results: function (data, page) {
return {results: data.results};
}
},
});
$("#writing_journal_author_tokens").select2("container").find("ul.select2-choices").sortable({
containment: 'parent',
start: function() { $("#writing_journal_author_tokens").select2("onSortStart"); },
update: function() { $("#writing_journal_author_tokens").select2("onSortEnd"); }
});
}
var preData = function(){ var preData = function(){
$("#writing_journal_author_tokens").select2('data', JSON.parse($("#writing_journal_author_tokens").attr('data-pre'))); $("#writing_journal_author_tokens").select2('data', JSON.parse($("#writing_journal_author_tokens").attr('data-pre')));
} }
o.use_select2();
uploadFiles(); uploadFiles();
tokesplits();
preData(); preData();
} }
@ -134,51 +94,11 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ //
// console.log("hi"); // console.log("hi");
var bindHandlers = function(){ var bindHandlers = function(){
o.simple_drop_down(); o.simple_drop_down();
o.use_select2();
} }
var tokesplits = function(){
$("#writing_journal_author_tokens").select2({
multiple: true,
minimumInputLength: -1,
width: "off",
formatResult: function movieFormatResult(coAuthor, container, query, escapeMarkup) {
var markup = "";
if (coAuthor.text !== undefined && coAuthor.email !== undefined) {
if(!coAuthor.email){
markup += coAuthor.text + " -- none email";
} else {
markup += coAuthor.text + " -- " + coAuthor.email;
}
}else if (coAuthor.email !== undefined) {
markup += coAuthor.text;
}
return markup;
},
ajax: {
url: "/panel/personal_journal/desktop/journal_pages/new.json",
dataType: 'json',
quietMillis: 100,
tokenSeparators: [","],
data: function (search, page) {
return {q: search};
},
results: function (data, page) {
return {results: data.results};
}
},
});
$("#writing_journal_author_tokens").select2("container").find("ul.select2-choices").sortable({
containment: 'parent',
start: function() { $("#writing_journal_author_tokens").select2("onSortStart"); },
update: function() { $("#writing_journal_author_tokens").select2("onSortEnd"); }
});
}
bindHandlers(); bindHandlers();
uploadFiles(); uploadFiles();
tokesplits();
} }
this.initializeJournalPapers.journal = function(){ // to open add pages in journal papers page this.initializeJournalPapers.journal = function(){ // to open add pages in journal papers page

View File

@ -51,7 +51,8 @@
size: "20", size: "20",
placeholder: t("personal_journal.journal_title"), placeholder: t("personal_journal.journal_title"),
class: "s_grid_12 s_grid", class: "s_grid_12 s_grid",
"autocomplete-list" => "journal_title_autocomplete_list", "autocomplete" => "/panel/personal_journal/desktop/journal_pages/new.json",
"autocomplete-format" => "--:[text,email]",
value: (@writing_journal.journal_title_translations[locale.to_s] rescue nil) %> value: (@writing_journal.journal_title_translations[locale.to_s] rescue nil) %>
<% end %> <% end %>
@ -104,6 +105,8 @@
class: "s_grid_12 s_grid", class: "s_grid_12 s_grid",
size: "20x2", size: "20x2",
placeholder: t("personal_journal.authors"), placeholder: t("personal_journal.authors"),
"autocomplete" => "/panel/personal_journal/desktop/journal_pages/new.json",
"autocomplete-format" => "--:[text,email]",
"data-pre" => generate_authors_name(@writing_journal.journal_co_author_ids) %> "data-pre" => generate_authors_name(@writing_journal.journal_co_author_ids) %>
<%#= f.fields_for :authors_translations do |f| %> <%#= f.fields_for :authors_translations do |f| %>
<%#= f.text_area locale, <%#= f.text_area locale,
@ -232,25 +235,6 @@
</div> </div>
--> -->
<script>
$(document).ready(function(){
$("#writing_conference_author_tokens").tokenInput("/panel/personal_conference/desktop/conference_pages/new.json", {
crossDomain: false,
prePopulate: $("#writing_conference_author_tokens").data("pre"),
theme: "facebook",
hintText: "<%=t("hintText")%>",
noResultsText: "<%=t("noResultsText")%>",
searchingText: "<%=t("searchingText")%>"
});
});
</script>
<script type="text/javascript">
orbitDesktop.prototype.initializeJournalPapers.journal_title_autocomplete_list = <%= @journal_candidate.to_json.html_safe %>;
// orbitDesktop.prototype.initializeJournalPapers.coauthor_autocomplete_list = <%= @co_author_candidate.to_json.html_safe %>;
</script>
<script> <script>
var get_html = function(old_id,new_id){ var get_html = function(old_id,new_id){
return ("<%= escape_javascript(add_attribute 'form_file', f, :writing_journal_files) %>").replace(old_id, new_id); return ("<%= escape_javascript(add_attribute 'form_file', f, :writing_journal_files) %>").replace(old_id, new_id);